
from flask_wtf import FlaskForm
from wtforms import StringField,PasswordField,SubmitField,IntegerField
from wtforms.validators import DataRequired,Email,EqualTo,NumberRange,Length
import email_validator

class register(FlaskForm):
    username = StringField(
        validators = [
            DataRequired(message="请填写用户名"),
            Length(2,7,message='长度不符合条件')
        ],
        render_kw = {
            "id": 'user_name',
            "placeholder":"请输入用户名",
            "class":"form-control ipt_list" ,
            "required" : False
            
        }
    )
    email = StringField(
        validators = [
            DataRequired(message="请填写邮箱"),
            Email(message="填写正确邮箱"),
            Length(4,36,message='长度不符合条件')
        ],
        render_kw = {
            "placeholder":"请输入邮箱",
            "class":"form-control ipt_list",
            "required" : False
       }
    )

    password = PasswordField(
        validators = [
            DataRequired(message="请填写密码"),
            Length(6,100,message='长度不符合条件')
        ],
        render_kw = {
            "placeholder":"请输入密码",
            "class":"form-control ipt_list",
            "required" : False
        }
    )

    submit = SubmitField("注册",
        render_kw = {
            "class":"btn btn-primary btn-block"
        }
    )

class login(FlaskForm):
    username = StringField(
        validators = [
            DataRequired(message="请填写用户名"),
        ],
        render_kw = {
            "placeholder":"请输入用户名",
            "class":"form-control ipt_list",
            "required" : False
        }
    )

    password = PasswordField(
        validators = [
            DataRequired(message="请填写密码"),
        ],
        render_kw = {
            "placeholder":"请输入密码",
            "class":"form-control ipt_list",
            "required" : False
        }
    )

    submit = SubmitField("登录",
        render_kw = {
            "class":"btn btn-primary btn-block"
        }
    )